namespace SmartSoft.Lists
{
    using SmartSoft;
    using SmartSoft.Controls;
    using SmartSoft.ADP;
    using System;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Windows.Forms;

    public class FormDmCvEditor : FormListEditor
    {
        private IContainer components;
        private LabelControl lblMa_Cv;
        private LabelControl lblTen_Cv;
        private LabelControl lblTen_Cv_E;
        private TextControl txtMa_Cv;
        private TextControl txtTen_Cv;
        private TextControl txtTen_Cv_E;

        public FormDmCvEditor()
        {
            this.InitializeComponent();
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormDmCvEditor));
            this.txtMa_Cv = new SmartSoft.Controls.TextControl();
            this.lblMa_Cv = new SmartSoft.Controls.LabelControl();
            this.txtTen_Cv = new SmartSoft.Controls.TextControl();
            this.lblTen_Cv = new SmartSoft.Controls.LabelControl();
            this.txtTen_Cv_E = new SmartSoft.Controls.TextControl();
            this.lblTen_Cv_E = new SmartSoft.Controls.LabelControl();
            this.SuspendLayout();
            // 
            // lblPhan_Loai
            // 
            this.lblPhan_Loai.Location = new System.Drawing.Point(12, 97);
            // 
            // txtMa_Loai1
            // 
            this.txtMa_Loai1.FirstFilter = "Type = \'KM1\'";
            this.txtMa_Loai1.Location = new System.Drawing.Point(123, 94);
            this.txtMa_Loai1.Size = new System.Drawing.Size(133, 20);
            this.txtMa_Loai1.TabIndex = 3;
            // 
            // txtMa_Loai2
            // 
            this.txtMa_Loai2.FirstFilter = "Type = \'KM2\'";
            this.txtMa_Loai2.Location = new System.Drawing.Point(259, 94);
            this.txtMa_Loai2.Size = new System.Drawing.Size(134, 20);
            this.txtMa_Loai2.TabIndex = 4;
            // 
            // txtMa_Loai3
            // 
            this.txtMa_Loai3.FirstFilter = "Type = \'KM3\'";
            this.txtMa_Loai3.Location = new System.Drawing.Point(396, 94);
            this.txtMa_Loai3.Size = new System.Drawing.Size(133, 20);
            this.txtMa_Loai3.TabIndex = 5;
            // 
            // txtMa_Cv
            // 
            this.txtMa_Cv.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtMa_Cv.CheckTextSearched = false;
            this.txtMa_Cv.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtMa_Cv.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtMa_Cv.Location = new System.Drawing.Point(123, 28);
            this.txtMa_Cv.MaxLength = 32;
            this.txtMa_Cv.Name = "txtMa_Cv";
            this.txtMa_Cv.OldValue = null;
            this.txtMa_Cv.Size = new System.Drawing.Size(133, 20);
            this.txtMa_Cv.TabIndex = 0;
            this.txtMa_Cv.UserTextLength = SmartSoft.AppInstance.TextControlLength.ItemCode;
            this.txtMa_Cv.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.All;
            this.txtMa_Cv.Value = ((object)(resources.GetObject("txtMa_Cv.Value")));
            // 
            // lblMa_Cv
            // 
            this.lblMa_Cv.AutoSize = true;
            this.lblMa_Cv.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblMa_Cv.Location = new System.Drawing.Point(12, 31);
            this.lblMa_Cv.Name = "lblMa_Cv";
            this.lblMa_Cv.Size = new System.Drawing.Size(64, 14);
            this.lblMa_Cv.TabIndex = 4;
            this.lblMa_Cv.Text = "Mã chức vụ";
            // 
            // txtTen_Cv
            // 
            this.txtTen_Cv.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txtTen_Cv.CheckTextSearched = false;
            this.txtTen_Cv.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtTen_Cv.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTen_Cv.Location = new System.Drawing.Point(123, 50);
            this.txtTen_Cv.MaxLength = 128;
            this.txtTen_Cv.Name = "txtTen_Cv";
            this.txtTen_Cv.OldValue = null;
            this.txtTen_Cv.Size = new System.Drawing.Size(406, 20);
            this.txtTen_Cv.TabIndex = 1;
            this.txtTen_Cv.UserTextLength = SmartSoft.AppInstance.TextControlLength.ItemDescription;
            this.txtTen_Cv.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.All;
            this.txtTen_Cv.Value = ((object)(resources.GetObject("txtTen_Cv.Value")));
            // 
            // lblTen_Cv
            // 
            this.lblTen_Cv.AutoSize = true;
            this.lblTen_Cv.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblTen_Cv.Location = new System.Drawing.Point(12, 53);
            this.lblTen_Cv.Name = "lblTen_Cv";
            this.lblTen_Cv.Size = new System.Drawing.Size(68, 14);
            this.lblTen_Cv.TabIndex = 4;
            this.lblTen_Cv.Text = "Tên chức vụ";
            // 
            // txtTen_Cv_E
            // 
            this.txtTen_Cv_E.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txtTen_Cv_E.CheckTextSearched = false;
            this.txtTen_Cv_E.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtTen_Cv_E.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTen_Cv_E.Location = new System.Drawing.Point(123, 72);
            this.txtTen_Cv_E.MaxLength = 128;
            this.txtTen_Cv_E.Name = "txtTen_Cv_E";
            this.txtTen_Cv_E.OldValue = null;
            this.txtTen_Cv_E.Size = new System.Drawing.Size(406, 20);
            this.txtTen_Cv_E.TabIndex = 2;
            this.txtTen_Cv_E.UserTextLength = SmartSoft.AppInstance.TextControlLength.ItemDescription;
            this.txtTen_Cv_E.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.All;
            this.txtTen_Cv_E.Value = ((object)(resources.GetObject("txtTen_Cv_E.Value")));
            // 
            // lblTen_Cv_E
            // 
            this.lblTen_Cv_E.AutoSize = true;
            this.lblTen_Cv_E.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblTen_Cv_E.Location = new System.Drawing.Point(12, 75);
            this.lblTen_Cv_E.Name = "lblTen_Cv_E";
            this.lblTen_Cv_E.Size = new System.Drawing.Size(73, 14);
            this.lblTen_Cv_E.TabIndex = 4;
            this.lblTen_Cv_E.Text = "Tên tiếng Anh";
            // 
            // FormDmCvEditor
            // 
            this.AddTitleText = "Thêm mới chức vụ";
            this.ClientSize = new System.Drawing.Size(546, 128);
            this.Controls.Add(this.lblTen_Cv_E);
            this.Controls.Add(this.lblTen_Cv);
            this.Controls.Add(this.lblMa_Cv);
            this.Controls.Add(this.txtTen_Cv_E);
            this.Controls.Add(this.txtTen_Cv);
            this.Controls.Add(this.txtMa_Cv);
            this.EditTitleText = "Sửa chức vụ";
            this.FirstFreeCode = "KM1";
            this.Name = "FormDmCvEditor";
            this.SecondFreeCode = "KM2";
            this.Text = "Thêm mới chức vụ";
            this.ThirdFreeCode = "KM3";
            this.Controls.SetChildIndex(this.lblPhan_Loai, 0);
            this.Controls.SetChildIndex(this.txtMa_Loai1, 0);
            this.Controls.SetChildIndex(this.txtMa_Loai2, 0);
            this.Controls.SetChildIndex(this.txtMa_Loai3, 0);
            this.Controls.SetChildIndex(this.txtMa_Cv, 0);
            this.Controls.SetChildIndex(this.txtTen_Cv, 0);
            this.Controls.SetChildIndex(this.txtTen_Cv_E, 0);
            this.Controls.SetChildIndex(this.lblMa_Cv, 0);
            this.Controls.SetChildIndex(this.lblTen_Cv, 0);
            this.Controls.SetChildIndex(this.lblTen_Cv_E, 0);
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        public override bool OnSave()
        {
            DataRow localCurrentRow;
            if (string.IsNullOrEmpty(this.txtMa_Cv.Text))
            {
                MessageBox.Show("Chưa nhập mã chức vụ!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return false;
            }
            if (string.IsNullOrEmpty(this.txtTen_Cv.Text))
            {
                MessageBox.Show("Chưa nhập tên chức vụ!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return false;
            }
            if (base.NewChecked)
            {
                localCurrentRow = base.LocalTable.NewRow();
            }
            else
            {
                localCurrentRow = base.LocalCurrentRow;
            }
            localCurrentRow["Ma_Cv"] = this.txtMa_Cv.Value;
            localCurrentRow["Ten_Cv"] = this.txtTen_Cv.Value;
            localCurrentRow["Ten_Cv_E"] = this.txtTen_Cv_E.Value;
            localCurrentRow["Ma_Loai1"] = base.txtMa_Loai1.Value;
            localCurrentRow["Ma_Loai2"] = base.txtMa_Loai2.Value;
            localCurrentRow["Ma_Loai2"] = base.txtMa_Loai2.Value;
            DmCvDataAccess access = new DmCvDataAccess();
            if (base.ShowMessage(localCurrentRow, access.SaveRow(base.NewChecked, localCurrentRow)))
            {
                return false;
            }
            if (base.NewChecked)
            {
                base.LocalTable.Rows.Add(localCurrentRow);
            }
            base.LocalCurrentRow = localCurrentRow;
            base.LocalTable.AcceptChanges();
            this.txtMa_Cv.Focus();
            return base.OnSave();
        }

        public override void OnShow()
        {
            this.txtMa_Cv.Value = base.LocalCurrentRow["Ma_Cv"];
            this.txtTen_Cv.Value = base.LocalCurrentRow["Ten_Cv"];
            this.txtTen_Cv_E.Value = base.LocalCurrentRow["Ten_Cv_E"];
            base.txtMa_Loai1.Value = base.LocalCurrentRow["Ma_Loai1"];
            base.txtMa_Loai2.Value = base.LocalCurrentRow["Ma_Loai2"];
            base.txtMa_Loai2.Value = base.LocalCurrentRow["Ma_Loai2"];
            base.OnShow();
        }
    }
}

